<template>
  <div class="el-kart">
    <div class="el-number">{{ data.name }}</div>
    <img :src="data | url" @click="show_dialog" />
    <div class="el-num">
      <span v-if="data.is_run_set == 1">{{ data.car_number }}</span>
    </div>
  </div>
</template>

<script>
import selectable_img from "@/assets/selectable.png";
import selected_img from "@/assets/selected.png";
import occupation_img from "@/assets/occupation.png";
import breakdown_img from "@/assets/breakdown.png";

export default {
  props: {
    data: {
      type: Object,
      default() {
        return {};
      }
    }
  },
  filters: {
    url(val) {
      if (val.car_status == 2) {
        return occupation_img;
      } else {
        if (val.is_run_set == 1) {
          return breakdown_img;
        } else {
          return selectable_img;
        }
      }
      return occupation_img;
    }
  },
  data() {
    return {
      selectable_img,
      selected_img,
      occupation_img,
      breakdown_img
    };
  },
  methods: {
    show_dialog() {
      this.$emit("showDialog", this.data);
    }
  }
};
</script>

<style lang="less" scoped>
.el-kart {
  padding: 15px;
  display: flex;
  align-items: center;
  flex-direction: column;
  cursor: pointer;
  img {
    width: 100%;
  }
  span {
    margin-top: 4px;
    color: #666;
  }
  .el-number {
    font-size: 12px;
    color: #666;
    margin-bottom: 4px;
    text-align: center;
  }
  .el-num {
    height: 24px;
  }
}
</style>
